#ifndef __MBM_MEMORY_ADAPTER_H__
#define __MBM_MEMORY_ADAPTER_H__

#ifdef __cplusplus
extern "C"
{
#endif

void mbm_memory_init(void);
void mbm_memory_deinit(void);


/**
 * @name mbm_malloc_ext_mem -Note:	Don't use it directly. Please use MBM_Malloc
 *
 * @param param1	-property	-discripe
 *
 * @return -discripe
 */
void *mbm_malloc_ext_mem(Int32 size, ImpCStr file, UInt32 line);

/**
 * @name mbm_free_ext_mem -Note:	Don't use it directly. Please use MBM_Free
 *
 * @param param1	-property	-discripe
 *
 * @return -discripe
 */
void mbm_free_ext_mem(void **p, ImpCStr file, UInt32 line);

/**
 * @name mbm_ext_mem_left_size -discripe
 *
 * @param param1	-property	-discripe
 *
 * @return -discripe
 */
UInt32 mbm_ext_mem_left_size(void);

void* mbm_asm_malloc(UInt32 size, ImpCStr file, UInt32 line);
void mbm_asm_free(void* p, ImpCStr file, UInt32 line);
UInt32 mbm_asm_leftsize(void);
ImpBool mbm_is_asm_mem(void* ptr);

/**
 * @name mbm_malloc_int_mem -discripe
 *
 * @param param1	-property	-discripe
 *
 * @return -discripe
 */
void *mbm_malloc_int_mem(Int32 size, ImpCStr file, UInt32 line);

/**
 * @name mbm_free_int_mem -discripe
 *
 * @param param1	-property	-discripe
 *
 * @return -discripe
 */
void mbm_free_int_mem(void **p, ImpCStr file, UInt32 line);

/**
 * @name mbm_int_mem_left_size -discripe
 *
 * @param param1	-property	-discripe
 *
 * @return -discripe
 */
UInt32 mbm_int_mem_left_size(void);

void* mbm_tcm_malloc(UInt32 size, ImpCStr file, UInt32 line);
void mbm_tcm_free(void* p, ImpCStr file, UInt32 line);
ImpBool mbm_is_tcm_mem(void* ptr);

#define MBM_Malloc(size)    mbm_malloc_ext_mem((size), __MODULE__, __LINE__)
#define MBM_Free(ptr)       mbm_free_ext_mem((void**)(&(ptr)), __MODULE__, __LINE__)

#define MBM_ASM_Malloc(size)    mbm_asm_malloc((size), __MODULE__, __LINE__)
#define MBM_ASM_Free(ptr)       mbm_asm_free((ptr), __MODULE__, __LINE__)

#define MBM_INT_Malloc(size)    mbm_malloc_int_mem((size), __MODULE__, __LINE__)
#define MBM_INT_Free(ptr)       mbm_free_int_mem((void**)(&(ptr)), __MODULE__, __LINE__)

#define MBM_TCM_Malloc(size)    mbm_tcm_malloc((size), __MODULE__, __LINE__)
#define MBM_TCM_Free(ptr)       mbm_tcm_free((ptr), __MODULE__, __LINE__)

#ifdef __cplusplus
}
#endif

#endif/* __MBM_MEMORY_ADAPTER_H__  */
